package com.net.url02;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * Administrator
 *
 * @author jiangbang
 * @date 2016/7/22
 */
public class URLDemo01 {

    public static void main(String[] args) throws IOException {
        URL url = new URL("http://www.baidu.com:8081/index.html?uname=11#aa");
//        url = new URL(url,"b.txt");
        System.out.println("协议："+ url.getProtocol());
        System.out.println("域名："+ url.getHost());
        System.out.println("端口："+ url.getPort());
        System.out.println("资源："+ url.getFile());
        System.out.println("相对路径："+ url.getPath());
        System.out.println("锚点："+ url.getRef());
        System.out.println("参数："+ url.getQuery());//?参数：存在锚点 返回null
//        System.out.println("参数："+ url.getDefaultPort());
//        System.out.println("参数："+ url.getAuthority());
//        System.out.println("参数："+ url.getAuthority());
//        System.out.println("参数："+ url.getUserInfo());
//        System.out.println("参数："+ url.getContent());
    }
}
